package router

import (
	"ci-control-backend/common/httpx"
	"ci-control-backend/controller"
	"ci-control-backend/middleware"
	"github.com/gin-gonic/gin"
)

var recordController *controller.RecordController

func init() {
	recordController = new(controller.RecordController)
}

func SetupRecordRoutes(r *gin.Engine) {
	// 以下API无需验证
	noAuth := r.Group("/record")
	noAuth.Use()
	{
		noAuth.PUT("/:key", httpx.Controller(recordController.PushLog))
	}

	// 以下API需要用户权限
	userAuth := r.Group("/record")
	userAuth.Use(httpx.Middleware(middleware.UserAuth))
	{
		userAuth.DELETE("/:id", httpx.Controller(recordController.DelRecord))
		userAuth.GET("/list", httpx.Controller(recordController.GetRecordList))
		userAuth.GET("/log", httpx.Controller(recordController.GetLog))
	}
}
